package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchWaterPlants;
import com.ruoyi.system.service.IDispatchWaterPlantsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水厂信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchWaterPlants")
public class DispatchWaterPlantsController extends BaseController
{
    @Autowired
    private IDispatchWaterPlantsService dispatchWaterPlantsService;

    /**
     * 查询水厂信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchWaterPlants:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchWaterPlants dispatchWaterPlants)
    {
        startPage();
        List<DispatchWaterPlants> list = dispatchWaterPlantsService.selectDispatchWaterPlantsList(dispatchWaterPlants);
        return getDataTable(list);
    }

    /**
     * 导出水厂信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchWaterPlants:export')")
    @Log(title = "水厂信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchWaterPlants dispatchWaterPlants)
    {
        List<DispatchWaterPlants> list = dispatchWaterPlantsService.selectDispatchWaterPlantsList(dispatchWaterPlants);
        ExcelUtil<DispatchWaterPlants> util = new ExcelUtil<DispatchWaterPlants>(DispatchWaterPlants.class);
        util.exportExcel(response, list, "水厂信息数据");
    }

    /**
     * 获取水厂信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchWaterPlants:query')")
    @GetMapping(value = "/{waterPlantsId}")
    public AjaxResult getInfo(@PathVariable("waterPlantsId") Long waterPlantsId)
    {
        return success(dispatchWaterPlantsService.selectDispatchWaterPlantsByWaterPlantsId(waterPlantsId));
    }

    /**
     * 新增水厂信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchWaterPlants:add')")
    @Log(title = "水厂信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchWaterPlants dispatchWaterPlants)
    {
        return toAjax(dispatchWaterPlantsService.insertDispatchWaterPlants(dispatchWaterPlants));
    }

    /**
     * 修改水厂信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchWaterPlants:edit')")
    @Log(title = "水厂信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchWaterPlants dispatchWaterPlants)
    {
        return toAjax(dispatchWaterPlantsService.updateDispatchWaterPlants(dispatchWaterPlants));
    }

    /**
     * 删除水厂信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchWaterPlants:remove')")
    @Log(title = "水厂信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{waterPlantsIds}")
    public AjaxResult remove(@PathVariable Long[] waterPlantsIds)
    {
        return toAjax(dispatchWaterPlantsService.deleteDispatchWaterPlantsByWaterPlantsIds(waterPlantsIds));
    }
}
